from openai import OpenAI


def call_local_ollama_deepseek():
    """
    调用本地使用Ollama部署的DeepSeek
    :return:
    """

    base_url = "http://localhost:11434/v1/"
    # api_key 需要有个值
    api_key = "ollama"
    client = OpenAI(
        base_url=base_url,
        api_key=api_key,
    )
    # 模型
    model = "deepseek-r1:1.5b"
    messages = [{"role": "user", "content": "你是谁"}]
    response = client.chat.completions.create(
        messages=messages,
        model=model,
    )

    print(response.choices[0].message.content)


if __name__ == '__main__':
    call_local_ollama_deepseek()
